$(function() {
    //
});

function onClickApp(){
    //document.getElementById("page_list").style.display="none";
}

wx.ready(function () {
    // 自定义分享内容及分享结果接口
    var myAppMsg = {
        title: gWechat.title,
        desc: gWechat.desc,
        link: gURL,
        imgUrl: gShareIcon,
        trigger: function (res) {
            //alert('用户点击发送给朋友');
        },
        success: function (res) {
            if (gMyParam && gMyParam.di && gMyParam.ui) {
                var postUrl = gAPIHOST+'/preview/usi';
                var sendData = {
                    di:gMyParam.di,
                    ui:gMyParam.ui,
                    rm:1,
                    vm:1,
                };
                $.post(postUrl, sendData, function(ret){
                    //
                });
            }
            alert('已分享');
        },
        cancel: function (res) {
            alert('已取消');
        },
        fail: function (res) {
            alert(JSON.stringify(res));
        }
    };

    var myTimeline = {
        title: gWechat.title,
        desc: gWechat.desc,
        link: gURL,
        imgUrl: gShareIcon,
        trigger: function (res) {
            //alert('用户点击分享朋友圈');
        },
        success: function (res) {
            if (gMyParam && gMyParam.di && gMyParam.ui) {
                var postUrl = gAPIHOST+'/preview/usi';
                var sendData = {
                    di:gMyParam.di,
                    ui:gMyParam.ui,
                    rm:2,
                    vm:1,
                };
                $.post(postUrl, sendData, function(ret){
                    //
                });
            }
            alert('已分享');
        },
        cancel: function (res) {
            alert('已取消');
        },
        fail: function (res) {
            alert(JSON.stringify(res));
        }
    };

    // 监听“分享给朋友”
    wx.onMenuShareAppMessage(myAppMsg);
    // 监听“分享到朋友圈”
    wx.onMenuShareTimeline(myTimeline);

});